﻿#ifndef PARAMETERMODEL_H
#define PARAMETERMODEL_H

#include <QObject>
#include <QAbstractListModel>
#include <QDebug>
#include "parameteritem.h"

class ParameterModel : public QAbstractListModel
{
    Q_OBJECT
public:
    ParameterModel(QObject *parent = nullptr);
    ~ParameterModel();

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index,int role = Qt::DisplayRole) const override;

    virtual QHash<int,QByteArray> roleNames() const override;

    void insertItem(int index,ParameterItem* item);

    Q_INVOKABLE void addItem(ParameterItem* item);

    void removeByItem(ParameterItem* item);

    void removeByIndex(int index);


    Q_INVOKABLE int count();


    void copyModel(ParameterModel* model);

    Q_INVOKABLE ParameterItem* itemAt(int index);

    Q_INVOKABLE void clear();

    Q_INVOKABLE QString getCurrentValue(int index);

    // 上载数据
    // Q_INVOKABLE void setUploadParamter();

    // 刷新数据
    void freshData();


private:

    QList <ParameterItem*> _list;

};

#endif // PARAMETERMODEL_H
